All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.table.AbstractTableModel

java.lang.Object
   |
   +----com.sun.java.swing.table.AbstractTableModel

public abstract class AbstractTableModel
extends Object
implements TableModel, Serializable
This abstract class provides default implementations for most of the methods in the TableModel interface. It takes care of the management of listners and provides some conveniences for generating TableModelEvents and dispatching them to the listeners. To create a concrete TableModel as a sublcass of AbstractTableModel you need only provide implementations for the following three methods:
  public int getRowCount();
  public int getColumnCount();
  public Object getValueAt(int row, int column);
  

Warning: serialized objects of this class will not be compatible with future swing releases. The current serialization support is appropriate for short term storage or RMI between Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.


Variable Index

 o listenerList
List of listeners

Constructor Index

 o AbstractTableModel()

Method Index

 o addTableModelListener(TableModelListener)
 o findColumn(String)
Convenience method for locating columns by name.
 o fireTableCellUpdated(int, int)
Notify all listeners that the value of the cell at (row, column) has been updated.
 o fireTableChanged(TableModelEvent)
Forward the given notification event to all TableModelListeners that registered themselves as listeners for this table model.
 o fireTableDataChanged()
Notify all listeners that all cell values in the table's rows may have changed.
 o fireTableRowsDeleted(int, int)
Notify all listeners that rows in the (inclusive) range [firstRow, lastRow] have been deleted.
 o fireTableRowsInserted(int, int)
Notify all listeners that rows in the (inclusive) range [firstRow, lastRow] have been inserted.
 o fireTableRowsUpdated(int, int)
Notify all listeners that rows in the (inclusive) range [firstRow, lastRow] have been updated.
 o fireTableStructureChanged()
Notify all listeners that the table's structure has changed.
 o getColumnClass(int)
Returns Object.class by default
 o getColumnCount()
Returns the number of columns managed by the data source object.
 o getColumnName(int)
Return a default name for the column using spreadsheet conventions: A, B, C, ...
 o getRowCount()
Returns the number of records managed by the data source object.
 o getValueAt(int, int)
Returns an attribute value for the cell at columnIndex and rowIndex.
 o isCellEditable(int, int)
This default implementation returns false for all cells
 o removeTableModelListener(TableModelListener)
 o setValueAt(Object, int, int)
This empty implementation is provided so users don't have to implement this method if their data model is not editable.

Variables

 o listenerList
 protected EventListenerList listenerList
List of listeners

Constructors

 o AbstractTableModel
 public AbstractTableModel()

Methods

 o getColumnName
 public String getColumnName(int column)
Return a default name for the column using spreadsheet conventions: A, B, C, ... Z, AA, AB, etc.

 o findColumn
 public int findColumn(String columnName)
Convenience method for locating columns by name. Implementation is naive so this should be overridden if this method is to be called often. This method is not in the TableModel interface and is not used by the JTable.

 o getColumnClass
 public Class getColumnClass(int columnIndex)
Returns Object.class by default

 o isCellEditable
 public boolean isCellEditable(int rowIndex,
                               int columnIndex)
This default implementation returns false for all cells

 o setValueAt
 public void setValueAt(Object aValue,
                        int rowIndex,
                        int columnIndex)
This empty implementation is provided so users don't have to implement this method if their data model is not editable.

 o addTableModelListener
 public void addTableModelListener(TableModelListener l)
 o removeTableModelListener
 public void removeTableModelListener(TableModelListener l)
 o fireTableDataChanged
 protected void fireTableDataChanged()
Notify all listeners that all cell values in the table's rows may have changed. The number of rows may also have changed and the JTable should redraw the table from scratch. The structure of the table, ie. the order of the columns is assumed to be the same.

See Also:
TableModelEvent, EventListenerList
 o fireTableStructureChanged
 protected void fireTableStructureChanged()
Notify all listeners that the table's structure has changed. The number of columns in the table, and the names and types of the new columns may be different from the previous state. If the JTable recieves this event and its autoCreateColumnsFromModel flag is set it discards any TableColumns that it had and reallocates default ones in the order they appear in the model. This is the same as calling setModel(TableModel) on the JTable.

See Also:
TableModelEvent, EventListenerList
 o fireTableRowsInserted
 protected void fireTableRowsInserted(int firstRow,
                                      int lastRow)
Notify all listeners that rows in the (inclusive) range [firstRow, lastRow] have been inserted.

See Also:
TableModelEvent, EventListenerList
 o fireTableRowsUpdated
 protected void fireTableRowsUpdated(int firstRow,
                                     int lastRow)
Notify all listeners that rows in the (inclusive) range [firstRow, lastRow] have been updated.

See Also:
TableModelEvent, EventListenerList
 o fireTableRowsDeleted
 protected void fireTableRowsDeleted(int firstRow,
                                     int lastRow)
Notify all listeners that rows in the (inclusive) range [firstRow, lastRow] have been deleted.

See Also:
TableModelEvent, EventListenerList
 o fireTableCellUpdated
 protected void fireTableCellUpdated(int row,
                                     int column)
Notify all listeners that the value of the cell at (row, column) has been updated.

See Also:
TableModelEvent, EventListenerList
 o fireTableChanged
 protected void fireTableChanged(TableModelEvent e)
Forward the given notification event to all TableModelListeners that registered themselves as listeners for this table model.

See Also:
addTableModelListener, TableModelEvent, EventListenerList

All Packages  Class Hierarchy  This Package  Previous  Next  Index